<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>prencar: D:/Workspace/Arduino/prencar/StateMaschine.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="prencar.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">prencar
   &#160;<span id="projectnumber">1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_state_maschine_8cpp.html','');
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">D:/Workspace/Arduino/prencar/StateMaschine.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_state_maschine_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;Arduino.h&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;<a class="code" href="_state_maschine_8h.html">StateMaschine.h</a>&quot;</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <a class="code" href="class_state_maschine.html">StateMaschine</a> <a class="code" href="class_state_maschine.html#ae63367f6117a93b862973b7756ce515c" title="Static reference to the singleton object.">StateMaschine::_instance</a>; 
<a name="l00005"></a>00005 <span class="keywordtype">boolean</span> <a class="code" href="class_state_maschine.html#a9c60433a0d4dba03bfe5422c0896b4ba">StateMaschine::_instanceCreated</a> = <span class="keyword">false</span>;
<a name="l00006"></a>00006 
<a name="l00011"></a><a class="code" href="class_state_maschine.html#a908a6b51448036bc23a7cd76acfcfbe0">00011</a> <a class="code" href="class_state_maschine.html">StateMaschine</a>* <a class="code" href="class_state_maschine.html#a908a6b51448036bc23a7cd76acfcfbe0">StateMaschine::getInstance</a>()
<a name="l00012"></a>00012 {
<a name="l00013"></a>00013   <span class="keywordflow">if</span> ( !<a class="code" href="class_state_maschine.html#a9c60433a0d4dba03bfe5422c0896b4ba">_instanceCreated</a> ){
<a name="l00014"></a>00014     <a class="code" href="class_state_maschine.html#ae63367f6117a93b862973b7756ce515c" title="Static reference to the singleton object.">_instance</a> = <a class="code" href="class_state_maschine.html#a869746d152d0a38b8d6142da3b420e85">StateMaschine</a>();
<a name="l00015"></a>00015     <a class="code" href="class_state_maschine.html#a9c60433a0d4dba03bfe5422c0896b4ba">_instanceCreated</a> = <span class="keyword">true</span>;
<a name="l00016"></a>00016 
<a name="l00017"></a>00017     <span class="comment">//do the configuration stuff so that a call to begin() from the outside of the</span>
<a name="l00018"></a>00018     <span class="comment">//class is not necessary</span>
<a name="l00019"></a>00019     <a class="code" href="class_state_maschine.html#ae63367f6117a93b862973b7756ce515c" title="Static reference to the singleton object.">_instance</a>.<a class="code" href="class_state_maschine.html#acdadfde97fc8449c816c1b489e2f4a22">begin</a>();
<a name="l00020"></a>00020   }
<a name="l00021"></a>00021   <span class="keywordflow">return</span> &amp;<a class="code" href="class_state_maschine.html#ae63367f6117a93b862973b7756ce515c" title="Static reference to the singleton object.">_instance</a>;
<a name="l00022"></a>00022 }
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 
<a name="l00028"></a><a class="code" href="class_state_maschine.html#a869746d152d0a38b8d6142da3b420e85">00028</a> <a class="code" href="class_state_maschine.html#a869746d152d0a38b8d6142da3b420e85">StateMaschine::StateMaschine</a>()
<a name="l00029"></a>00029 {
<a name="l00030"></a>00030   <a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> = <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a3dcefcfc73c46cd08fedd1d3c0dbaad1">notStarted</a>;
<a name="l00031"></a>00031   <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a> = <span class="keyword">false</span>;
<a name="l00032"></a>00032 }
<a name="l00033"></a>00033 
<a name="l00037"></a><a class="code" href="class_state_maschine.html#acdadfde97fc8449c816c1b489e2f4a22">00037</a> <span class="keywordtype">void</span> <a class="code" href="class_state_maschine.html#acdadfde97fc8449c816c1b489e2f4a22">StateMaschine::begin</a>(){
<a name="l00038"></a>00038   <a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a> = <a class="code" href="class_state_maschine.html#a908a6b51448036bc23a7cd76acfcfbe0">Communication::getInstance</a>();
<a name="l00039"></a>00039   <a class="code" href="class_state_maschine.html#a1739f27286f50fbc99a6212c029c79d5" title="The reference to the configuration class.">_conf</a> = <a class="code" href="class_state_maschine.html#a908a6b51448036bc23a7cd76acfcfbe0">Configuration::getInstance</a>();
<a name="l00040"></a>00040   <a class="code" href="class_state_maschine.html#a91050d9a782c56bbceb4f51255707685" title="The reference to the move class.">_move</a> = <a class="code" href="class_state_maschine.html#a908a6b51448036bc23a7cd76acfcfbe0">Move::getInstance</a>();
<a name="l00041"></a>00041   <a class="code" href="class_state_maschine.html#a47fe78de48af82060f3f40399ef2c2d2" title="The reference to the LiftCube class.">_liftCube</a> = <a class="code" href="class_state_maschine.html#a908a6b51448036bc23a7cd76acfcfbe0">LiftCube::getInstance</a>();
<a name="l00042"></a>00042   <a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#afac0ad1ff185b7e5f9b47428cb2e5e48">begin</a>();
<a name="l00043"></a>00043   <a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a0e6f8f5d7f869edfaf34cf3e74676a86">begin</a>();
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00051"></a><a class="code" href="class_state_maschine.html#a1095131aa8e6e9537f481b5f425395e2">00051</a> <span class="keywordtype">void</span> <a class="code" href="class_state_maschine.html#a1095131aa8e6e9537f481b5f425395e2">StateMaschine::doJob</a>(){
<a name="l00052"></a>00052 
<a name="l00053"></a>00053   <a class="code" href="class_state_maschine.html#a5551d00a5224f595833b75969c2ca64a">checkCommands</a>();
<a name="l00054"></a>00054 
<a name="l00055"></a>00055   <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> == <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a96474cef925f487adb48d8db38ee3455">followingFirstLine</a>){
<a name="l00056"></a>00056     <span class="comment">//go to the next state if the car has reached the curve (see LineFollow::hasReachedCurve)</span>
<a name="l00057"></a>00057     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#accb339a7a953d66032b9329a2b3a1b4d" title="Is set to true, if the left curve line is reached.">hasReachedCurve</a> || <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a>){
<a name="l00058"></a>00058       <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a8e86865de2ed193e0b3a38fdfe7bd52a">firstTurn</a>);
<a name="l00059"></a>00059       <a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a2f70c4b1efef29cdf04dff01e6a90336">startIt</a>();
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061     <span class="keywordflow">else</span>{
<a name="l00062"></a>00062       <a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#a93ff35747f2ae3bb26998f07243afc3c">doJob</a>();
<a name="l00063"></a>00063     }
<a name="l00064"></a>00064   }
<a name="l00065"></a>00065   <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> == <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a8e86865de2ed193e0b3a38fdfe7bd52a">firstTurn</a>){
<a name="l00066"></a>00066     <span class="comment">//go to the next state if the car has finished the curve (see CurveLeft::drivingCurveIsFinished)</span>
<a name="l00067"></a>00067     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a0f7c63a8242780be79a08482380d9caa" title="This variable is set to true as soon as the curve is driven fully.">drivingCurveIsFinished</a> || <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a>){
<a name="l00068"></a>00068       <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8abdec259af1c38a7275c56d3e3a00430b">followingSecondLine</a>);
<a name="l00069"></a>00069       <a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#a5f3e76e795bacff24be60b7f65d84d94">startIt</a>();
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071     <span class="keywordflow">else</span>{
<a name="l00072"></a>00072       <a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a34930d2641dbbd389c536999a560f158">doJob</a>();
<a name="l00073"></a>00073     }
<a name="l00074"></a>00074   }
<a name="l00075"></a>00075   <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> == <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8abdec259af1c38a7275c56d3e3a00430b">followingSecondLine</a>){
<a name="l00076"></a>00076     <span class="comment">//go to the next state if the car has reached the curve (see LineFollow::hasReachedCurve)</span>
<a name="l00077"></a>00077     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#accb339a7a953d66032b9329a2b3a1b4d" title="Is set to true, if the left curve line is reached.">hasReachedCurve</a> || <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a>){
<a name="l00078"></a>00078       <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a2f8eb7f135d44d0a27d117159480d80f">secondTurn</a>);
<a name="l00079"></a>00079       <a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a2f70c4b1efef29cdf04dff01e6a90336">startIt</a>();
<a name="l00080"></a>00080     }
<a name="l00081"></a>00081     <span class="keywordflow">else</span>{
<a name="l00082"></a>00082       <a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#a93ff35747f2ae3bb26998f07243afc3c">doJob</a>();
<a name="l00083"></a>00083     }
<a name="l00084"></a>00084   }
<a name="l00085"></a>00085   <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> == <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a2f8eb7f135d44d0a27d117159480d80f">secondTurn</a>){
<a name="l00086"></a>00086     <span class="comment">//go to the next state if the car has finished the curve (see CurveLeft::drivingCurveIsFinished)</span>
<a name="l00087"></a>00087     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a0f7c63a8242780be79a08482380d9caa" title="This variable is set to true as soon as the curve is driven fully.">drivingCurveIsFinished</a> || <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a>){
<a name="l00088"></a>00088       <span class="comment">//changeState(followingThirdLineToCube);</span>
<a name="l00089"></a>00089       <span class="comment">//for now just stop the car</span>
<a name="l00090"></a>00090       <a class="code" href="class_state_maschine.html#a91050d9a782c56bbceb4f51255707685" title="The reference to the move class.">_move</a>-&gt;<a class="code" href="class_move.html#a237261f2dd8fc115129f0ba998f13183">performFastStop</a>();
<a name="l00091"></a>00091       <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8aaf38e35232eb6728664f98c8110d11a4">finished</a>);
<a name="l00092"></a>00092     }
<a name="l00093"></a>00093     <span class="keywordflow">else</span>{
<a name="l00094"></a>00094       <a class="code" href="class_state_maschine.html#a705593d70b7955850568e80694c27e35">curveLeft</a>.<a class="code" href="class_curve_left.html#a34930d2641dbbd389c536999a560f158">doJob</a>();
<a name="l00095"></a>00095     }
<a name="l00096"></a>00096   }
<a name="l00097"></a>00097 
<a name="l00098"></a>00098   <span class="comment">//set forceChangeSate back to false in order to continue normally</span>
<a name="l00099"></a>00099   <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a> = <span class="keyword">false</span>;
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101 
<a name="l00106"></a><a class="code" href="class_state_maschine.html#a5551d00a5224f595833b75969c2ca64a">00106</a> <span class="keywordtype">void</span> <a class="code" href="class_state_maschine.html#a5551d00a5224f595833b75969c2ca64a">StateMaschine::checkCommands</a>(){
<a name="l00107"></a>00107   <a class="code" href="class_command.html" title="A Command object represents a command sent from the host software.">Command</a> c;
<a name="l00108"></a>00108 
<a name="l00109"></a>00109   <span class="comment">//the following commands are only available, if the parcours is not started</span>
<a name="l00110"></a>00110   <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> == <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a3dcefcfc73c46cd08fedd1d3c0dbaad1">notStarted</a> || <a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> == <a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8aaf38e35232eb6728664f98c8110d11a4">finished</a>){
<a name="l00111"></a>00111     <span class="comment">//check for command 200</span>
<a name="l00112"></a>00112     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 200)){
<a name="l00113"></a>00113       <a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#a9db172747e4457a6b01f8d27ed41ac39" title="Calibrates the sensors.">calibrateSensors</a>();
<a name="l00114"></a>00114     }
<a name="l00115"></a>00115 
<a name="l00116"></a>00116     <span class="comment">//check for command 300</span>
<a name="l00117"></a>00117     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 300)){
<a name="l00118"></a>00118       <span class="keywordtype">int</span>* parameters = c.<a class="code" href="class_command.html#a213973ca7ffaf1385a959ceab49f5065">parameters</a>;
<a name="l00119"></a>00119       <span class="keywordtype">int</span> highestImplementedState = 4;
<a name="l00120"></a>00120       <span class="keywordflow">if</span>(parameters[0] &gt; highestImplementedState){
<a name="l00121"></a>00121         <span class="keywordtype">int</span> p[2];
<a name="l00122"></a>00122         p[0] = parameters[0];
<a name="l00123"></a>00123         p[1] = highestImplementedState;
<a name="l00124"></a>00124         <a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(151, p, 2);
<a name="l00125"></a>00125         <a class="code" href="class_state_maschine.html#ae028d25d4b664d805e0f516a49cfdb23">stopParcours</a>();
<a name="l00126"></a>00126       }
<a name="l00127"></a>00127       <span class="keywordflow">else</span>{
<a name="l00128"></a>00128         <span class="comment">//send the current configuration</span>
<a name="l00129"></a>00129         <a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17e42ee6dbbaa353944d63e7d5dee25a">sendCurrentConfiguration</a>();
<a name="l00130"></a>00130         <span class="comment">//if the desired state is &gt; than 1, start with that state. If the parameter is 0 or 1 just start with</span>
<a name="l00131"></a>00131         <span class="comment">//the first state.</span>
<a name="l00132"></a>00132         <span class="keywordflow">if</span>(parameters[0] &gt; 1){
<a name="l00133"></a>00133           <a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> = (<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8">TParcoursState</a>)(parameters[0] - 1);
<a name="l00134"></a>00134           <a class="code" href="class_state_maschine.html#acf147371c0034a418702eb1544b8e620" title="Will be set to true if the stateMaschine shall switch to the next state immediately.">forceChangeSate</a> = <span class="keyword">true</span>;
<a name="l00135"></a>00135           <a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(205, <a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> + 1);
<a name="l00136"></a>00136         }
<a name="l00137"></a>00137         <span class="keywordflow">else</span>{
<a name="l00138"></a>00138           <a class="code" href="class_state_maschine.html#aaca597f41ba735fce3ef0eb06e4fda18">startParcours</a>();
<a name="l00139"></a>00139         }
<a name="l00140"></a>00140       }
<a name="l00141"></a>00141     }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143     <span class="comment">//check for command 101</span>
<a name="l00144"></a>00144     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 101)){
<a name="l00145"></a>00145       <span class="keywordtype">int</span>* parameters = c.<a class="code" href="class_command.html#a213973ca7ffaf1385a959ceab49f5065">parameters</a>;
<a name="l00146"></a>00146       <a class="code" href="class_state_maschine.html#a1739f27286f50fbc99a6212c029c79d5" title="The reference to the configuration class.">_conf</a>-&gt;<a class="code" href="class_configuration.html#a13c417c35f720cae9917b7bed7ceb159">updateConfiguration</a>(parameters);
<a name="l00147"></a>00147       <a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(102);
<a name="l00148"></a>00148     }
<a name="l00149"></a>00149 
<a name="l00150"></a>00150     <span class="comment">/*----------- offline control car -----------*/</span>
<a name="l00151"></a>00151     <span class="comment">//check for command 400</span>
<a name="l00152"></a>00152     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 400)){
<a name="l00153"></a>00153       <span class="keywordtype">int</span>* parameters = c.<a class="code" href="class_command.html#a213973ca7ffaf1385a959ceab49f5065">parameters</a>;
<a name="l00154"></a>00154       <a class="code" href="class_state_maschine.html#a91050d9a782c56bbceb4f51255707685" title="The reference to the move class.">_move</a>-&gt;<a class="code" href="class_move.html#a9c5dc5c3a98abece0c2f40085c3601be">controlMotors</a>((<a class="code" href="_move_8h.html#a4d576498f070661245f38f5f34d34f02">TMotorDirection</a>)parameters[0], parameters[1], (<a class="code" href="_move_8h.html#a4d576498f070661245f38f5f34d34f02">TMotorDirection</a>)parameters[2], parameters[3]);
<a name="l00155"></a>00155     }
<a name="l00156"></a>00156 
<a name="l00157"></a>00157     <span class="comment">//check for command 401</span>
<a name="l00158"></a>00158     <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 401)){
<a name="l00159"></a>00159       <span class="keywordtype">int</span>* parameters = c.<a class="code" href="class_command.html#a213973ca7ffaf1385a959ceab49f5065">parameters</a>;
<a name="l00160"></a>00160       <a class="code" href="class_state_maschine.html#a47fe78de48af82060f3f40399ef2c2d2" title="The reference to the LiftCube class.">_liftCube</a>-&gt;<a class="code" href="class_lift_cube.html#a6b6c013383282736029056541de33844">setHoistPosition</a>(parameters[0]);
<a name="l00161"></a>00161     }
<a name="l00162"></a>00162   }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164   <span class="comment">//check for command 301</span>
<a name="l00165"></a>00165   <span class="keywordflow">if</span>(<a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 301)){
<a name="l00166"></a>00166     <a class="code" href="class_state_maschine.html#ae028d25d4b664d805e0f516a49cfdb23">stopParcours</a>();
<a name="l00167"></a>00167   }
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169 
<a name="l00173"></a><a class="code" href="class_state_maschine.html#aaca597f41ba735fce3ef0eb06e4fda18">00173</a> <span class="keywordtype">void</span> <a class="code" href="class_state_maschine.html#aaca597f41ba735fce3ef0eb06e4fda18">StateMaschine::startParcours</a>(){
<a name="l00174"></a>00174   <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a96474cef925f487adb48d8db38ee3455">followingFirstLine</a>);
<a name="l00175"></a>00175   <a class="code" href="class_state_maschine.html#a3307f4f89ffd7ebb3faa55467c32a71d">lineFollow</a>.<a class="code" href="class_line_follow.html#a5f3e76e795bacff24be60b7f65d84d94">startIt</a>();
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 
<a name="l00181"></a><a class="code" href="class_state_maschine.html#ae028d25d4b664d805e0f516a49cfdb23">00181</a> <span class="keywordtype">void</span> <a class="code" href="class_state_maschine.html#ae028d25d4b664d805e0f516a49cfdb23">StateMaschine::stopParcours</a>(){
<a name="l00182"></a>00182   <a class="code" href="class_state_maschine.html#a91050d9a782c56bbceb4f51255707685" title="The reference to the move class.">_move</a>-&gt;<a class="code" href="class_move.html#a237261f2dd8fc115129f0ba998f13183">performFastStop</a>();
<a name="l00183"></a>00183   <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8a3dcefcfc73c46cd08fedd1d3c0dbaad1">notStarted</a>);
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185 
<a name="l00190"></a><a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">00190</a> <span class="keywordtype">void</span> <a class="code" href="class_state_maschine.html#a5b9f3dfb795afbb28c1beeaa6f6512a4">StateMaschine::changeState</a>(<a class="code" href="_state_maschine_8h.html#ad5f3c64cf1a6afd0af12270f4a539ce8">TParcoursState</a> newState){
<a name="l00191"></a>00191   <a class="code" href="class_state_maschine.html#adbdb287052ba80eb22fd4a910edc0115">parcoursState</a> = newState;
<a name="l00192"></a>00192   <a class="code" href="class_state_maschine.html#a375a5c409935687eab5d7185c25b2e97" title="The reference to the serial communication class.">_com</a>-&gt;<a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(100, newState);
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 
<a name="l00195"></a>00195 
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 
<a name="l00200"></a>00200 
<a name="l00201"></a>00201 
<a name="l00202"></a>00202 
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 
<a name="l00205"></a>00205 
<a name="l00206"></a>00206 
<a name="l00207"></a>00207 
<a name="l00208"></a>00208 
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 
<a name="l00211"></a>00211 
<a name="l00212"></a>00212 
<a name="l00213"></a>00213 
<a name="l00214"></a>00214 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_state_maschine_8cpp.html">StateMaschine.cpp</a>      </li>

    <li class="footer">Generated on Thu Apr 26 2012 09:42:56 for prencar by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.0 </li>
   </ul>
 </div>


</body>
</html>
